
#ifndef Velyn_TriangleMesh_h
#define Velyn_TriangleMesh_h

#include <vector>

#include "Vertex.h"

using namespace std;

namespace Velyn {
    
    class TriangleMesh {
    
    private:
        
        vector<Vertex> positions;
        vector<Vertex> normals;
        
        vector<int> triangles;
        
    public:
        
        void addPosition(const float x, const float y, const float z) {
            Vertex v;
            v.set(x, y, z);
            positions.push_back(v);
        }
        
        void addNormal(const float x, const float y, const float z) {
            Vertex v;
            v.set(x, y, z);
            normals.push_back(v);
        }
        
        void addTriangle(const int index0, const int index1, const int index2) {
            triangles.push_back(index0);
            triangles.push_back(index1);
            triangles.push_back(index2);
        }
        
        void printPositions() {
            vector<Vertex>::iterator positionIterator;
            
            for(positionIterator = positions.begin(); positionIterator != positions.end(); positionIterator++) {
                positionIterator->print();
            }
        }
        
        void printNormals() {
            vector<Vertex>::iterator normalIterator;
            
            for(normalIterator = normals.begin(); normalIterator != normals.end(); normalIterator++) {
                normalIterator->print();
            }
        }
        
        void printTriangles() {
            vector<int>::iterator triangleIterator;
            
            for(triangleIterator = triangles.begin(); triangleIterator != triangles.end();) {
                cout << "[ " << *triangleIterator;
                triangleIterator++;
                cout << " " << *triangleIterator;
                triangleIterator++;
                cout << " " << *triangleIterator;
                triangleIterator++;
                cout << " ]" << endl;
            }
        }
    };
}

#endif